package chapter4;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class Audience {
	
	@Pointcut("execution(* charter4.Performance.*(..))")
	public void performance() {
	}
	
	@Around("performance()")
	public void watching(ProceedingJoinPoint jp){
		try {
			silence();
			jp.proceed();
		} catch (Throwable e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		applause();
	}
	
	private void silence() {
		System.out.println("Silence cellphones before the performance");
	}
	private void applause() {
		System.out.println("CLAP CLAP CLAP");
	}
}
